import 'package:flutter/material.dart';
import 'package:rabbit_mobile/widget/custom_cache_image_widget/index.dart';

class GoodsDetailsInfo extends StatefulWidget {
  final String name;
  final String desc;
  final String price;
  final String mainPicture;
  const GoodsDetailsInfo({
    super.key,
    required this.desc,
    required this.mainPicture,
    required this.name,
    required this.price,
  });

  @override
  State<GoodsDetailsInfo> createState() => _GoodsDetailsInfoState();
}

class _GoodsDetailsInfoState extends State<GoodsDetailsInfo> {
  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Container(
          padding: const EdgeInsets.symmetric(horizontal: 24),
          width: double.infinity,
          height: 60,
          decoration: const BoxDecoration(color: Color(0xFF00CE8A)),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              RichText(
                text: TextSpan(
                  text: "¥",
                  style: const TextStyle(fontSize: 12, color: Colors.white),
                  children: [
                    TextSpan(
                      text: widget.price,
                      style: const TextStyle(fontSize: 20, color: Colors.white),
                    )
                  ],
                ),
              ),
              CustomCacheImageWidget(
                imageUrl: widget.mainPicture,
                width: 80,
                height: 40,
                fit: BoxFit.fill,
              ),
            ],
          ),
        ),
        Container(
          padding: const EdgeInsets.only(left: 12),
          width: double.infinity,
          height: 60,
          decoration: const BoxDecoration(
            color: Colors.white
          ),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(widget.name, style: const TextStyle(fontSize: 16, color: Colors.black), maxLines: 1, overflow: TextOverflow.ellipsis,),
              Text(widget.desc, style: const TextStyle(fontSize: 14, color: Colors.red), maxLines: 1, overflow: TextOverflow.ellipsis,),
            ],
          ),
        )
      ],
    );
  }
}
